package com.xuecheng.content.api;

import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "教师管理接口", tags = "教师管理")
@RestController
public class courseTeacherController {
    @Autowired
    private CourseTeacherService courseTeacherService;

    @ApiOperation("课程老师展示")
    @GetMapping("/courseTeacher/list/{courseId}")
    public List<CourseTeacher> getTeacher(@PathVariable("courseId")Long courseId){
        Long company = 1232141425L;
        List<CourseTeacher> teachers = courseTeacherService.getTeachers(company,courseId);
        return teachers;
    }
    @ApiOperation("课程老师添加和修改")
    @PostMapping("/courseTeacher")
    public CourseTeacher saveAndUpdate(@RequestBody CourseTeacher courseTeacher){
        CourseTeacher newCourseTeacher = courseTeacherService.saveAndUpdate(courseTeacher);
        return newCourseTeacher;
    }
    @ApiOperation("课程老师删除")
    @DeleteMapping("/courseTeacher/course/{courseId}/{id}")
    public void deleteTeacher(@PathVariable("courseId")Long courseId,@PathVariable("id")Long id){
        Long company = 1232141425L;
        courseTeacherService.deleteTeacher(company,courseId,id);
    }
}
